<?php
class Bliss_DataReport_Export_CSV extends Bliss_DataReport_Export_Abstract
{
	protected function init()
	{
		$this->setFilename('data_report');
	}

	protected function setHeaders()
	{
		header("Expires: 0");
		header("Cache-control: private");
		header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
		header("Content-Description: File Transfer");
		header("Content-Type: application/vnd.ms-excel");
		header("Content-disposition: attachment; filename={$this->_filename}.csv");
	}
	
	public function output()
	{
		$this->setHeaders();

		$rows	= array();
		foreach($this->getResults() as $set) {
			$row = array();
			foreach($set as $key=>$item) {
				if($item->isVisible() && $key != 'id') {
					$row[$key]	= '"'.$item->getRawValue().'"';
				}
			}
			$rows[]	= implode(',', $row);
		}

		echo implode("\n", $rows);
		exit;
	}
}
?>
